<?php


namespace app\api\model\Video;



use think\facade\Db;
use think\Model;

class VideoCourseRelationModel extends Model
{
    /**
     * 数据表名
     * @var string
     */
    protected $name = "video_course_relation";

    /**
     * 根据条件查询多条
     * @param $where
     * @return array
     * @throws
     */
    public static function getVideoCourseRelationWhereMore($where,$filed="c.*")
    {
        $list = Db::name('video_course_relation')
            ->alias('vcr')
            ->join('course c','c.id = vcr.course_id')
            ->join('course_cate_relation ccr','ccr.course_id = c.id')
            ->join('school s','s.id = c.school_id','left')
            ->join('school_area sa','sa.id = s.area_id','left')
            ->join('course_cate cc','cc.id = ccr.cate_id')
            ->field($filed)
            ->where($where)
            ->select()->toArray();
        return $list;
    }

    /**
     * 统计
     * @param $where
     * @return int
     */
    public static function getVideoCourseRelationCountWhere($where)
    {
        $count = Db::name("video_course_relation")->where($where)->count();
        return $count;
    }
}
